package com.sqy.service.collection;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.sqy.dao.BannerMapper;
import com.sqy.dao.IconsMapper;
import com.sqy.dao.LikeMapper;
import com.sqy.dao.RecommendMapper;
import com.sqy.entity.*;
import com.sqy.entity.collection.HomeCollection;
import com.sqy.service.DahongpaoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HomeCollectionService {
    @Autowired
    BannerMapper bannerMapper;

    @Autowired
    IconsMapper  iconsMapper;

    @Autowired
    LikeMapper likeMapper;

    @Autowired
    RecommendMapper recommendMapper;

    @Autowired
    DahongpaoService dahongpaoService;



    public List<Banner> getBannerList(Integer id){
        LambdaQueryWrapper<Banner> wrapper = new LambdaQueryWrapper<>();
          wrapper.eq(id != null,Banner::getIsShow,id);

        List<Banner> banners = bannerMapper.selectList(wrapper);
        return  banners;
    }

    public List<Icons> getIconsList(Integer id){
        LambdaQueryWrapper<Icons> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(id != null,Icons::getIsShow,id);


        List<Icons> icons = iconsMapper.selectList(wrapper);
        return  icons;

    }

    public  List<Likes> getLikeList(Integer id){
        LambdaQueryWrapper<Likes> wrapper = new LambdaQueryWrapper<>();

        wrapper.eq(id != null,Likes::getIsShow,id);

        List<Likes> likes = likeMapper.selectList(wrapper);

        return  likes;
    }


    public   List<Recommend> getRecommendList(Integer id){

        LambdaQueryWrapper<Recommend> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(id != null,Recommend::getIsShow,id);

        List<Recommend> recommendList = recommendMapper.selectList(wrapper);

        return  recommendList;
    }

    public List<Dahongpao> getDahongpaoList(Integer id){

        LambdaQueryWrapper<Dahongpao> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(id != null,Dahongpao::getIsShow,id);

        List<Dahongpao> list = dahongpaoService.list(wrapper);
        return list;
    }




    public HomeCollection getHomeCollectionList(Integer id){

        return new HomeCollection(
                getBannerList(id),
                getIconsList(id),
                getLikeList(id),
                getRecommendList(id),
                getDahongpaoList(id));
    }

}
